<!--  -->
<template>
  <div class="record-list">
    <Nav title="往期记录">
      <template v-slot:left>
        <span class="back" @click="$router.back()"></span>
      </template>
    </Nav>
    <div class="winner show_public">
      <div class="winner-tip">本期幸运者</div>
      <div class="attend-item">
        <div class="flex justify-between aligin-center">
          <img class="avator" :src="activityDetail.avatar_url" alt="">
          <span class="ml-8 mr-auto f-12">{{activityDetail.nickname}}购买了</span>
          <span class="color-gray f-10">{{activityDetail.created_time}}</span>
        </div>
        <div class="attend-info flex">
          <img class="product-img" :src="activityDetail.pic_cover_mid" alt="">
          <div class="flex flex-column justify-between ml-8 flex-1">
            <div class="flex justify-between">
              <span class="ellipsis w-200">{{activityDetail.goods_name}}</span>
              <span class="color-gray">¥{{activityDetail.price}}</span>
            </div>
            <div class="flex justify-between color-red mb-8">
              <span>获得活动号码:{{activityDetail.numbers}}</span>
              <span>x {{activityDetail.goods_num}}</span>
            </div>
          </div>
          <div class="info-divide"></div>
        </div>
      </div>
      <div class="rule">
        <div class="rule-cal flex aligin-center">
          <span>本期幸运号码:</span>
          <span>{{activityDetail.luck_number}} = (</span>
          <div>
            <div>{{activityDetail.winningNumber}}</div>
            <div class="line"></div>
            <div>{{activityDetail.power}}</div>
          </div>
          <span class="rest">)的余数+100001</span>
        </div>
      </div>
      <div class="word mt-26">公式说明：</div>
      <div
        class="word"
        v-if="activityDetail.l_type!=2"
      >括号内分子取值是人满后最新的时时彩开奖号码，号码由中国彩票中心提供，本平台只取用开奖结果，以保证中奖结果的偶然性。</div>
      <div class="word" v-else>
        <div>1、例如参与时间在：12:35:22，则参与时间的时分秒排列取值123522</div>
        <div>2、本次开奖所有参与时间取值之和为{{activityDetail.winningNumber}}，获奖号码是：{{activityDetail.luck_number}}</div>
      </div>
    </div>
    <div class="divide-line"></div>
    <Attend :attendList.sync="attendList"></Attend>
    <div class="loading-bottom mt-10 f-14" v-if="loading">加载中...</div>
    <div class="loading-bottom mt-10 f-14" v-if="noMore">没有更多了</div>
  </div>
</template>

<script>
import Nav from "../../components/Nav";
import Scroll from "../../components/Scroll";
import Page from "../../mixin/page";
import { historyDetail } from "../../api/api";
import Attend from "../../components/Attend";
export default {
  mixins: [Page],
  components: { Nav, Scroll, Attend },
  data() {
    return {
      activityDetail: {},
      attendList: []
    };
  },
  computed: {},
  watch: {},
  methods: {
    _api() {
      historyDetail({
        page: this.current_page + 1,
        key: this.$route.params.key,
        id: this.$route.params.id,
        issue_id: this.$route.params.issue_id
      }).then(({ data: { result } }) => {
        if (this.current_page == 0) {
          this.activityDetail = result;
        }
        if (result.list && result.list.length != 0) {
          this.attendList = [...this.attendList, ...result.list];
          this.current_page += 1;
          this.last_page = this.current_page + 1;
        } else {
          this.last_page = this.current_page;
        }
        this.loading = false;
      });
    }
  },
  created() {},
  mounted() {
    this._api();
    window.onscroll = () => {
      //变量scrollTop是滚动条滚动时，距离顶部的距离
      var scrollTop =
        document.documentElement.scrollTop || document.body.scrollTop;

      //变量windowHeight是可视区的高度
      var windowHeight =
        document.documentElement.clientHeight || document.body.clientHeight;
      //变量scrollHeight是滚动条的总高度
      var scrollHeight =
        document.documentElement.scrollHeight || document.body.scrollHeight;
      //滚动条到底部的条件
      var ua = navigator.userAgent.toLowerCase();
      var isWeixin = ua.indexOf("micromessenger") != -1;
      if (isWeixin) {
        if (scrollTop + windowHeight + 10 >= scrollHeight && scrollTop != 0) {
          this.pageToEnd();
        }
      } else {
        if (scrollTop + windowHeight + 56 >= scrollHeight && scrollTop != 0) {
          this.pageToEnd();
        }
      }
    };
  },
  updated() {}, //生命周期 - 更新之后
  destroyed() {} //生命周期 - 销毁完成
};
</script>
<style lang='less' scoped>
@import url("../../assets/style/mixin"); //引入公共css类
.f-15 {
  font-size: 15px;
}
.ml-53 {
  margin-left: 53px;
}
.record-list {
  height: 100%;
  .scroll-wrap {
    height: calc(100% - 45px);
    overflow: hidden;
  }
  .join_con {
    overflow: hidden;
    box-sizing: border-box;
    height: calc(100% - 400px);
  }
  .join_con_top img {
    width: 28px;
    height: 28px;
    border-radius: 100%;
  }
  .join_con_bottom {
    margin-left: 46px;
  }
  .join_con_btmgoods img {
    width: 50px;
    height: 50px;
    padding: 16px 9px 10px 0;
  }
  .winner {
    position: relative;
    margin: 10px 17px;
    .winner-tip {
      line-height: 26px;
      text-align: center;
      font-size: 15px;
      color: #cd1704;
    }
    .winner-content {
      background: #faf4f4;
    }
    .mask-icon {
      position: absolute;
      top: 0;
      left: 0;
      height: 72px;
      width: 72px;
      background: url("../../assets/imgs/win_logo.png");
      background-size: 100% 100%;
    }
  }
  .winner-detail {
    height: 46px;
    padding: 0 17px 0 7px;
    background: #ef3d4d;
  }
  .check-detail {
    width: 84px;
    height: 25px;
    border: 1px solid rgba(255, 255, 255, 1);
    border-radius: 4px;
  }
  .body {
    padding: 0 15px 10px 15px;
    box-sizing: border-box;
    .product-name {
      height: 40px;
      font-size: 15px;
      line-height: 20px;
      font-weight: bold;
    }
    .product-img {
      width: 100%;
      height: 200px;
      border-radius: 5px;
    }
    .progress-wrapper {
      position: relative;
      width: 100%;
      height: 6px;
      background: #eee;
      border-radius: 3px;
    }
    .progress {
      position: absolute;
      top: 0;
      left: 0;
      height: 100%;
      border-radius: 3px;
      .bg-1();
    }
    .power {
      display: inline-block;
      width: 17px;
      height: 17px;
      .bg-image("../../assets/imgs/power-red");
      background-size: 100% 100%;
    }
    .receive-count {
      display: inline-block;
      width: 15px;
      height: 15px;
      .bg-image("../../assets/imgs/receive-red");
      background-size: 100% 100%;
    }
    .color-red {
      color: #f3515a;
    }
    .line-height-19 {
      line-height: 19px;
    }
  }
  .loading-bottom {
    width: 100%;
    text-align: center;
  }
}
.rule {
  height: 40px;
  font-size: 11px;
  color: #fff;
  background: rgba(205, 23, 4, 1);
  border-radius: 0px 0px 5px 5px;
  .rule-cal {
    padding: 0 4px;
    height: 40px;
    text-align: center;
    .line {
      margin: 6px 0;
      width: 80px;
      height: 1px;
      background: #fff;
    }
    .rest {
      margin-left: 6px;
      text-align: left;
      font-size: 12px;
    }
  }
}
.word {
  font-size: 12px;
  line-height: 24px;
  color: #aaaaaa;
}
.w-200 {
  width: 200px;
}
.attend-item {
  padding: 8px 14px 13px 16px;
  border-bottom: 1px solid#F8F8F8;
  font-size: 12px;
  .avator {
    width: 26px;
    height: 26px;
    border-radius: 50%;
  }
  .attend-info {
    margin-left: 30px;
    padding: 5px;
    background: rgba(248, 248, 248, 1);
    .product-img {
      width: 40px;
      height: 40px;
      flex-shrink: 0;
    }
    .flex-1 {
      flex: 1;
    }
    .flex-column {
      flex-direction: column;
    }
    .color-red {
      color: #f8597f;
    }
    .info-divide {
      margin-top: 14px;
      width: 330px;
      height: 1px;
      background: #f8f8f8;
      &:last-child {
        display: none;
      }
    }
  }
}
</style>